from os import path
from dotenv import load_dotenv
from pydantic_settings import BaseSettings as Base

__all__ = ['get_settings']

ENV_FILES = ('.env', '.env.prod')
ROOT_PATH = path.dirname(path.abspath(path.join(__file__, '..')))


class BaseSettings(Base):
    """配置基类"""

    class Config:
        env_file = ENV_FILES
        env_file_encoding = 'utf-8'


class Settings(BaseSettings):
    user_name: str = 'telchina'
    user_password: str = '123456'
    post_url: str = "http://127.0.0.1:19000/receiveData"
    post_open: bool = False
    ws_url: str = "wss://10.10.50.72:8088/ws"
    file_url_prefix: str = "http://123.232.113.233:55000/telchina-filesystem/download?sourceFile="



def get_settings() -> Settings:
    # 读取配置
    for f in ENV_FILES:
        load_dotenv(dotenv_path=path.join(ROOT_PATH, f))
    return Settings()
